package com.bw.servlet;

import com.bw.dao.CustomerDao;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/***************************
 FileAction:

 CreateTime:2022-05-06 14:50
 Author:Aaking-aline
 ****************************/
@WebServlet("/DeleteServlet")
public class DeleteServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

    @SneakyThrows
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 如果我在这个方法里  能接收到  前端发送过来的  要删除的记录的  id值  是不是就可以在这个位置通过dao层提供的删除方法  删除数据库中记录
        String id = request.getParameter("id");
        System.out.println("id值是:" + id);

        new CustomerDao().deleteCustomerById(id);
    }
}
